﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
    EnableViewState="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head id="Head1" runat="server">
    <title>FBR Tax Calculator</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" defaultbutton="ButtonCalculateIncomeTax" enableviewstate="false"
    defaultfocus="TextBoxTotalTaxableIncome" runat="server">
    <asp:ScriptManager ID="MainScriptManager" runat="server" />
    <asp:UpdatePanel ID="pnlHelloWorld" runat="server">
        <ContentTemplate>
            <div>
                <table style="width: 100%;">
                    <tr>
                        <td colspan="3">
                            <table style="width: 100%;">
                                <tr>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="headerTextstyle" colspan="2" >
                                        <h1>
                                            FBR Tax Calculator</h1>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="subHeaderTextstyle" colspan="2">
                                        <h2>New Income Tax Calculations 2012-2013</h2>
                                        </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 22%;">
                            &nbsp;
                        </td>
                        <td style="border: 1px solid #D4D4D4; background-color: #F2F2F2;">
                            <table style="width: 100%;">
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td width="15%">
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle" width="30%">
                                        <asp:RadioButton ID="RadioButtonSalaried" onclick="radioButtonClicked(this)" runat="server"
                                            Checked="True" GroupName="IncomeType" Text="Salaried" EnableViewState="False" />
                                        &nbsp;
                                        <asp:RadioButton ID="RadioButtonSelf" onclick="radioButtonClicked(this)" runat="server" GroupName="IncomeType"
                                            TabIndex="1" Text="Self" EnableViewState="False" />
                                    </td>
                                    <td width="20%">
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Monthy Salary:
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxMonthlyIncome" runat="server" TabIndex="2" Width="100%" onblur="ControlBlur(this)" onFocus="ControlFocused(this.id)"
                                            EnableViewState="False" MaxLength="14">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RangeValidator ID="RangeValidatorMonthlyIncome" runat="server" ControlToValidate="TextBoxMonthlyIncome"
                                            ErrorMessage="Please enter valid monthly income" MaximumValue="99999999999999"
                                            MinimumValue="0" Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Eid/Christmas Bonus:
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxEidChristmasBonus" runat="server" TabIndex="3" Width="100%"
                                            onblur="ControlBlur(this)"  onFocus="ControlFocused(this.id)" EnableViewState="False" 
                                            MaxLength="14">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RangeValidator ID="RangeValidatorEidChristmasBonus" runat="server" ErrorMessage="Please enter valid Please enter valid eid/christmas bonus"
                                            ControlToValidate="TextBoxEidChristmasBonus" MaximumValue="99999999999999" MinimumValue="0"
                                            Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Performance Bonus:
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxPerformanceBonus" runat="server" TabIndex="4" Width="100%"
                                            onblur="ControlBlur(this)"  onFocus="ControlFocused(this.id)" EnableViewState="False" 
                                            MaxLength="14">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RangeValidator ID="RangeValidatorPerformanceBonus" runat="server" ControlToValidate="TextBoxPerformanceBonus"
                                            ErrorMessage="Please enter valid performance bonus" MaximumValue="99999999999999"
                                            MinimumValue="0" Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Leave Encashment:
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxLeaveEncashment" runat="server" TabIndex="5" Width="100%"
                                            onblur="ControlBlur(this)"  onFocus="ControlFocused(this.id)" EnableViewState="False" 
                                            MaxLength="14">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RangeValidator ID="RangeValidatorLeaveEncashment" runat="server" ControlToValidate="TextBoxLeaveEncashment"
                                            ErrorMessage="Please enter valid leave encashment" MaximumValue="99999999999999"
                                            MinimumValue="0" Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Overtime:
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxOvertime" runat="server" TabIndex="6" Width="100%" onblur="ControlBlur(this)"
                                            onFocus="ControlFocused(this.id)" EnableViewState="False" MaxLength="14">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RangeValidator ID="RangeValidatorOverTime" runat="server" ControlToValidate="TextBoxOverTime"
                                            ErrorMessage="Please enter valid overtime" MaximumValue="99999999999999" MinimumValue="0"
                                            Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Other:
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxOtherIncome" runat="server" TabIndex="7" Width="100%" onblur="ControlBlur(this)"
                                            onFocus="ControlFocused(this.id)" EnableViewState="False" MaxLength="14">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RangeValidator ID="RangeValidatorOther" runat="server" ControlToValidate="TextBoxOtherIncome"
                                            ErrorMessage="Please enter valid value" MaximumValue="99999999999999" MinimumValue="0"
                                            Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td class="inputControlsTextStyle">
                                        Gratuity:<label style="font-size:smaller; font-style:italic">(First exempt Rs. 
                                        75,000 or 50% whichever is lesser)</label></td>
                                    <td class="inputControlsTextStyle" valign="top">
                                        <asp:TextBox ID="TextBoxGratuity" runat="server" EnableViewState="False" 
                                            onFocus="ControlFocused(this.id)" MaxLength="14" onblur="ControlBlur(this)" TabIndex="8" 
                                            Width="100%">0</asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle" valign="top">
                                        <asp:RangeValidator ID="RangeValidatorGratuity" runat="server" 
                                            ControlToValidate="TextBoxGratuity" Display="Dynamic" EnableViewState="False" 
                                            ErrorMessage="Please enter valid gratuity" MaximumValue="99999999999999" 
                                            MinimumValue="0" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        Total Taxable Income:<asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*"></asp:Label>
                                    </td>
                                    <td class="inputControlsTextStyle">
                                        <asp:TextBox ID="TextBoxTotalTaxableIncome" runat="server" TabIndex="9" Width="100%"
                                            EnableViewState="False" onFocus="ControlFocused(this.id)" MaxLength="16"></asp:TextBox>
                                    </td>
                                    <td class="validatorsTextStyle">
                                        &nbsp;
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorTotalTaxableIncome" runat="server"
                                            ControlToValidate="TextBoxTotalTaxableIncome" ErrorMessage="Please enter total taxable income"
                                            Font-Italic="True" Display="Dynamic" EnableViewState="False"></asp:RequiredFieldValidator>
                                        <asp:RangeValidator ID="RangeValidatorTotalIncome" runat="server" ControlToValidate="TextBoxTotalTaxableIncome"
                                            ErrorMessage="Please enter valid taxable income" MaximumValue="9999999999999999"
                                            MinimumValue="0" Display="Dynamic" EnableViewState="False" Type="Double"></asp:RangeValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td style="text-align: right" class="inputControlsTextStyle">
                                        <asp:Button ID="ButtonCalculateIncomeTax" runat="server" OnClick="ButtonCalculateIncomeTax_Click"
                                            TabIndex="10" Text="Calculate" EnableViewState="False" OnClientClick="return  ControlBlur(this)"/>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td style="text-align: right" class="inputControlsTextStyle">
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td colspan="2" style="background-color: #DFDFDF;">
                                        <table style="width: 100%">
                                            <tr>
                                                <td style="width: 60%" class="inputControlsTextStyle">
                                                    Annual Tax Liability:
                                                </td>
                                                <td style="width: 40%" class="outputLablesTextStyle">
                                                    <asp:Label ID="LabelAnnualIncomeTax" runat="server" EnableViewState="False"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="inputControlsTextStyle">
                                                    Monthly Tax Liability:
                                                </td>
                                                <td class="outputLablesTextStyle">
                                                    <asp:Label ID="LabelMonthlyIncomeTax" runat="server" EnableViewState="False"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="inputControlsTextStyle">
                                                    Net Annual Income:
                                                </td>
                                                <td class="outputLablesTextStyle">
                                                    <asp:Label ID="LabelNetAnnualSalary" runat="server" EnableViewState="False"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="inputControlsTextStyle">
                                                    Net Monthly Salary:
                                                </td>
                                                <td class="outputLablesTextStyle">
                                                    <asp:Label ID="LabelNetMonthlySalary" runat="server" EnableViewState="False"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td class="style7">
                                        &nbsp;
                                    </td>
                                    <td class="messageLabelTextStyle" colspan="3">
                                        <asp:Label ID="LabelMessage" runat="server" EnableViewState="False" 
                                            Enabled="False"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                </td>
                <td style="width: 22%;">
                </td>
                </tr>
                <tr>
                    <td style="width: 22%;">
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td style="width: 22%;">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td style="width: 22%;">
                        &nbsp;
                    </td>
                    <td class="messageLabelTextStyle">
                        * Calculations are not legally bound
                    </td>
                    <td align="right" class="hyperlinkTextStyle">
                                    <a href="mailto:'FBR Income Tax Calculator Support' (support@taxcalculator.com.pk)">support@taxcalculator.com.pk</a></td>
                </tr>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
    <script type="text/javascript">

        function radioButtonClicked(obj) {
            if (obj.id == "RadioButtonSelf") {

                document.getElementById("TextBoxMonthlyIncome").disabled = true;
                document.getElementById("TextBoxEidChristmasBonus").disabled = true;
                document.getElementById("TextBoxPerformanceBonus").disabled = true;
                document.getElementById("TextBoxLeaveEncashment").disabled = true;
                document.getElementById("TextBoxOvertime").disabled = true;
                document.getElementById("TextBoxGratuity").disabled = true;
                document.getElementById("TextBoxOtherIncome").disabled = true;
            }
            else if (obj.id == "RadioButtonSalaried") {
                document.getElementById("TextBoxMonthlyIncome").disabled = false;
                document.getElementById("TextBoxEidChristmasBonus").disabled = false;
                document.getElementById("TextBoxPerformanceBonus").disabled = false;
                document.getElementById("TextBoxLeaveEncashment").disabled = false;
                document.getElementById("TextBoxOvertime").disabled = false;
                document.getElementById("TextBoxGratuity").disabled = false;
                document.getElementById("TextBoxOtherIncome").disabled = false;
            }
        }

        function ControlBlur(controlID) {

            var monthlyIncome = parseInt(document.getElementById("TextBoxMonthlyIncome").value)
            alert("monthly income: " + monthlyIncome);
            var eidChritmasBonus = parseInt(document.getElementById("TextBoxEidChristmasBonus").value)
            var performanceBonus = parseInt(document.getElementById("TextBoxPerformanceBonus").value)
            var leaveEncashment = parseInt(document.getElementById("TextBoxLeaveEncashment").value)
            var overtime = parseInt(document.getElementById("TextBoxOvertime").value)
            var gratuity = parseInt(document.getElementById("TextBoxGratuity").value)
            var other = parseInt(document.getElementById("TextBoxOtherIncome").value)

            var totalTaxableIncome = 0

            if (monthlyIncome > 0) {
                totalTaxableIncome = totalTaxableIncome + (monthlyIncome * 12)
                alert("total taxable income: " + totalTaxableIncome);
            }
            else {
                document.getElementById("TextBoxMonthlyIncome").value = 0
            }
            if (eidChritmasBonus > 0) {
                totalTaxableIncome = totalTaxableIncome + eidChritmasBonus
            }
            else {
                document.getElementById("TextBoxEidChristmasBonus").value = 0
            }
            if (performanceBonus > 0) {
                totalTaxableIncome = totalTaxableIncome + performanceBonus
            }
            else {
                document.getElementById("TextBoxPerformanceBonus").value = 0
            }
            if (leaveEncashment > 0) {
                totalTaxableIncome = totalTaxableIncome + leaveEncashment
            }
            else {
                document.getElementById("TextBoxLeaveEncashment").value = 0
            }
            if (overtime > 0) {
                totalTaxableIncome = totalTaxableIncome + overtime
            }
            else {
                document.getElementById("TextBoxOvertime").value = 0
            }
            if (gratuity > 0) {
                totalTaxableIncome = totalTaxableIncome + gratuity
            }
            else {
                document.getElementById("TextBoxGratuity").value = 0
            }
            if (other > 0) {
                totalTaxableIncome = totalTaxableIncome + other
            }
            else {
                document.getElementById("TextBoxOtherIncome").value = 0
            }

            alert("total taxable income: " + totalTaxableIncome);
            if (document.getElementById("TextBoxTotalTaxableIncome").value == NaN || controlID !== "ButtonCalculateIncomeTax") {
                document.getElementById("TextBoxTotalTaxableIncome").value = totalTaxableIncome;
            }

            alert("total taxable income: " + document.getElementById("TextBoxTotalTaxableIncome").value);


        }

        function ControlFocused(controlID) {
            if (document.getElementById(controlID).value == 0)
                document.getElementById(controlID).value = "";
        }

        
    </script>
    <script type="text/javascript">

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-32998298-1']);
        _gaq.push(['_setDomainName', 'taxcalculator.com.pk']);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
</body>
</html>
